const {fork} = require('child_process');
const path = require('path');
//两个进程监听同一个服务
const child = fork('http.js', {
  cwd: path.join(__dirname, 'test')
});

const http = require('http');

const server = http.createServer((req, res) => {
  res.end('父进程接受处理请求');
}).listen(3000);

child.send('server', server/* 可以是Socket|Server */ ); // 向子进程发消息
